home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / DL4FBI / BEACONS.BAS < prev    next >
BASIC Source File  |  1997-08-15  |  8KB  |  232 lines

  1. DECLARE SUB READPARAMETER ()
  2. DECLARE SUB TIMESET ()
  3. DECLARE SUB MYTIMESET ()
  4. DECLARE SUB PHONETIMESET ()
  5. DECLARE SUB PREPARETS870 ()
  6. DECLARE SUB SCANBEACONS ()
  7.  
  8. DEFINT A-Z: OPTION BASE 1
  9. DIM signa(5, 18) AS INTEGER  'signalstrength (frequency,station)
  10. DIM t(5, 18) AS STRING 'time of sample HH:MM:SS
  11. DIM sig(10) AS INTEGER 'signalstrengths in 3rd second of transmission
  12. DIM cals(18) AS STRING  'callsigns of the beacons
  13. DIM qth(18) AS STRING  'locations of the beacons
  14. DIM qrg(5) AS STRING  'frequencies in Hz
  15. DIM kom(10) AS STRING  'commands for TS870
  16. DIM pri(5, 18) AS STRING 'string for print of results
  17. DIM sn(5, 18) AS INTEGER  'noise strength
  18. DIM comz(1) AS STRING
  19. SHARED signa(),t(),sig(),cals(),qth(),qrg(),kom(),pri(),sn(),comz()
  20. 'end dim and definitions
  21. CALL READPARAMETER  'read the parameterfile C:\BEACON.PAR
  22. CALL PREPARETS870  'identify TS870 and set global parameters
  23. SELECT CASE kom(5)
  24. CASE "1"
  25. CALL TIMESET  'set PC's seconds timer to UTC or local time by DCF  1)
  26. CASE "2"
  27. CALL MYTIMESET 'GPS or WWVB must be installed
  28. CASE "3"
  29. CALL PHONETIMESET 'timeset by phone time signals
  30. END SELECT
  31. CALL SCANBEACONS 'scanning the beacons
  32. SELECT CASE kom(4) 'type of output
  33. CASE "1" 'screen only
  34. CASE "3" 'screen and hardcopy
  35. FOR i = 1 TO 5: FOR j = 1 TO 18
  36. LPRINT ; pri(i, j)
  37. NEXT j: NEXT i
  38. CASE "5"'screen and ASCII-file
  39. OPEN "a:\BEACON.TXT" FOR OUTPUT AS #3
  40. FOR i = 1 TO 5: FOR j = 1 TO 18
  41. WRITE #3, pri(i, j)
  42. NEXT j: NEXT i: CLOSE 3
  43. CASE "7" 'screen and hardcopy and ASCII-file
  44. OPEN "a:\BEACON.TXT" FOR OUTPUT AS #4
  45. FOR i = 1 TO 5: FOR j = 1 TO 18
  46. LPRINT ; pri(i, j)
  47. WRITE #4, pri(i, j)
  48. NEXT j: NEXT i: CLOSE 4
  49. END SELECT
  50. SYSTEM
  51.  
  52. SUB MYTIMESET  SHARED'//////////////////////////////////////////////////////
  53. CLS:LOCATE 8,2
  54. PRINT;"Missing subprogram <MYTIMESET>. Program aborted":end
  55. 'insert a program for GPS or WWVB
  56.  
  57. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  58.  
  59.  
  60. SUB PHONETIMESET  SHARED'///////////////////////////////////////////////////
  61.  
  62. SHELL "TIME"
  63.  
  64. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  65.  
  66. SUB PREPARETS870 SHARED'////////////////////////////////////////////////////
  67.  
  68. 'Definitions
  69. PS$ = "PS1;" 'power on
  70. ID$ = "ID;" 'ID-number (TS870:15)
  71. AI$ = "AI0;" 'AI-number (see Kenwood-manual page 89)
  72. SM$ = "SM;" 'command for reading S-Meter
  73. CW$ = "MD3;" 'command for mode cw
  74. VFO$ = "FR0;"  'rx on VFO a
  75.  
  76. 'Power on and identification of TS870:
  77. IF kom(1)="3" THEN
  78.   ida$="ID015;"
  79. ELSE
  80. OPEN comz(1) FOR RANDOM AS #1   'open serial port COM2
  81.    PRINT #1, PS$  'power on
  82.    PRINT #1, AI$  'answer only on request (not automatically)
  83.    trash$ = INPUT$(LOC(1), #1)  'clean buffer of serial port
  84.    PRINT #1, ID$  'ask for ID of transceiver
  85.    te& = TIMER
  86.    WHILE TIMER - te& <= .8: WEND  'wait for answer
  87.    ida$ = INPUT$(LOC(1), #1)  'read the answer (time critical!)
  88.    PRINT #1, VFO$ 'VFO A, RX
  89.    PRINT #1, CW$ 'mode cw
  90.    PRINT #1, kom(2) 'antenna number
  91.    PRINT #1, kom(3) 'filterbandwidth
  92.    CLOSE 1   'close serial port COM2
  93. END IF
  94.  IF LEFT$(ida$, 2) = "?;" THEN ida$ = RIGHT$(ida$, 6)  'delete random ?;' s
  95. 'sent by TS870 when its processor is busy
  96.   IF ida$ = "ID015;" THEN
  97. CLS : LOCATE 8, 2
  98.    PRINT ; "transceiver identified ! Program will continue...."
  99.  ELSE
  100.    CLS : LOCATE 8, 2
  101.    PRINT ; "wrong or missing transceiver"
  102.    PRINT ; "program aborted"
  103.    SLEEP 20
  104.    END
  105.  END IF
  106.  
  107. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  108.  
  109. SUB READPARAMETER  SHARED'//////////////////////////////////////////////////
  110.  
  111. OPEN "C:\BEACON.PAR" FOR INPUT AS #1
  112. FOR i = 1 TO 18: INPUT #1, cals(i), qth(i): NEXT i
  113. FOR i = 1 TO 5: INPUT #1, qrg(i): NEXT i
  114. FOR i = 1 TO 10: INPUT #1, kom(i): NEXT i
  115. CLOSE 1
  116. FOR i = 1 TO 5:  'qrg to TS870-format
  117. qrg(i) = "FA000" + qrg(i) + ";": NEXT i
  118. comz(1) = "COM" + LTRIM$(RTRIM$(kom(1))) 'part of command for serial port of PC
  119. comz(1) = comz(1) + ":9600,N,8,1,DS,CS,CD" 'command for serial port of PC
  120. kom(2) = "AN" + LTRIM$(RTRIM$(kom(2))) + ";"   'antenna-command
  121. kom(3) = LEFT$(kom(3), 2)
  122. kom(3) = "FW00" + LTRIM$(RTRIM$(kom(3))) + ";"  'filter bandwidth
  123. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  124.  
  125. SUB SCANBEACONS  SHARED'////////////////////////////////////////////////////
  126.  
  127. SM$ = "SM;"   'command for S-Meter"
  128. CLS : LOCATE 8, 2: PRINT ; "transceiver identified, all O.K. , please wait..."
  129.  
  130. 'scanning stations (j=1 to 18) and frequencies (i=1 to 5):
  131.  
  132. WHILE FIX(TIMER) MOD 180 <> 0
  133. z = 180 - FIX(TIMER) MOD 180   'time until scanning
  134. IF z = 180 THEN z = 0
  135. LOCATE 9, 2
  136. PRINT ; "synchronization to 3rd minute. "; z; " seconds until start of scan.."
  137. WEND
  138. PRINT ; " synchronization successful. Scan will take 16 minutes from now "
  139. PRINT
  140. FOR i = 1 TO 5                  '5 frequencies
  141.   FOR j = 1 TO 18               '18 stations
  142.  
  143.      IF j = 1 THEN
  144.        IF i > 1 THEN
  145.       te& = TIMER
  146.       WHILE TIMER - te& < 10: WEND 'time-offset for new frequency
  147.       END IF
  148.       IF kom(1) <> "3" THEN
  149.       OPEN comz(1) FOR OUTPUT AS #1
  150.       PRINT #1, qrg(i)    ' new frequency
  151.        CLOSE 1
  152.      END IF
  153.      END IF
  154. te& = TIMER
  155. WHILE TIMER - te& <= 3!: WEND      'wait for second no 3 (100 watts-signal)
  156. IF kom(1)="3" THEN
  157. s$=""
  158. FOR k = 1 TO 10
  159. s$=s$+"SM0015;"
  160. te!=TIMER
  161. WHILE TIMER - te!<=.1 : WEND
  162. NEXT k
  163. ELSE
  164.  
  165.    OPEN comz(1) FOR RANDOM AS #1
  166.    FOR k = 1 TO 10        'during first 100 watts-signal the S-meter
  167.     PRINT #1, SM$         'will be read 10 times
  168.     te! = TIMER            'ask every 0.1 seconds
  169.     WHILE TIMER - te! <= .1: WEND
  170.     NEXT k
  171.     s$ = INPUT$(LOC(1), #1) 'input from buffer
  172. CLOSE
  173. END IF
  174.  
  175. FOR ii = 1 TO 10
  176. sig(ii) = VAL(MID$(s$, (5 + 7 * (ii - 1)), 2)) 'evalute response
  177. NEXT ii
  178.  
  179. FOR m = 1 TO 10  'looking for maximum out of array of 10 values
  180. g = sig(m)
  181. FOR n = 1 TO 10
  182. IF g > sig(n) THEN sig(n) = 0
  183. NEXT n
  184. NEXT m
  185. res = 0
  186. FOR l = 1 TO 10
  187. IF sig(l) > 0 THEN res = sig(l)   'found maximum
  188. NEXT l
  189.  
  190.    signa(i, j) = res     'store maximum
  191. tim$ = TIME$ 'time of last signal:t(i, j) = TIME$'time of reception HH:MM:SS
  192.    sg$ = STR$(res): sg$ = LTRIM$(RTRIM$(sg$))   'convert for printing
  193.    IF LEN(sg$) = 1 THEN sg$ = "0" + sg$
  194.    qrgp$ = MID$(qrg(i), 6, 5)
  195.    qrgp$ = LEFT$(qrgp$, 2) + "." + RIGHT$(qrgp$, 3) + " " + "MHz "
  196.  zw$ = " " + cals(j) + " " + qth(j) + " " + qrgp$
  197. zw$ = zw$ + " " + tim$ + " " + " S-Meter S/N:" + " " + sg$ + "/"
  198. pri(i, j) = zw$
  199. PRINT ; pri(i, j);  'prints one result to screen
  200. te& = TIMER
  201. WHILE TIMER - te& <= 4: WEND 'wait for 8 th' second
  202. IF kom(1)="3" THEN
  203. snn$="SM0005;"
  204. te! = TIMER
  205. WHILE TIMER-te! <=0.9 : WEND
  206. ELSE
  207. OPEN comz(1) FOR RANDOM AS #1
  208. PRINT #1, SM$'ask for s-noise
  209. WHILE LOC(1) < 7 OR TIMER - te& < 0.9: WEND
  210. snn$ = INPUT$(LOC(1), #1)
  211. sn(i, j) = VAL(MID$(snn$, 5, 2))
  212. CLOSE
  213. END IF
  214. snn$ = LTRIM$(RTRIM$(MID$(snn$, 5, 2)))'noisestrength
  215. IF LEN(snn$) = 1 THEN snn$ = "0" + snn$
  216. PRINT ; snn$
  217. pri(i, j) = pri(i, j) + snn$
  218.    WHILE FIX(TIMER) MOD 10 <> 0: WEND  'wait for next sample
  219.   NEXT j
  220. NEXT i
  221. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  222.  
  223. SUB TIMESET  SHARED'////////////////////////////////////////////////////////
  224. 'This subroutine is for setting time by time signals broadcast from DCF77
  225. 'which can only received in Europe. Receiver and appropriate software
  226. 'must be installed in your computer. Source: Conrad Electronic, Hirschau
  227. 'Klaus-Conrad-Strasse 1, D92240 Hirschau, Germany. 1997-catalog page 1032
  228. 'order-nr. 975770-99. Price: DM 149.90, kit: DM 119.90  + s/h
  229. SHELL "C:\DCF.EXE"
  230. END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  231.  
  232.